const fs = require('fs');

const filePath = 'd:\\Users\\zhansiji\\entry\\src\\main\\ets\\commos\\types.ets';
const content = fs.readFileSync(filePath, 'utf8');

// 提取所有 id
const idMatches = content.match(/id:\s*(\d+)/g);
if (!idMatches) {
    console.log('❌ 未找到任何 id');
    process.exit(1);
}

const ids = idMatches.map(match => parseInt(match.match(/\d+/)[0]));

console.log(`📊 总共找到 ${ids.length} 个 id`);
console.log(`📈 id 范围: ${Math.min(...ids)} - ${Math.max(...ids)}`);

// 检查是否连续
let isConsecutive = true;
let missingIds = [];
let duplicateIds = [];

// 检查重复
const idCounts = {};
ids.forEach(id => {
    idCounts[id] = (idCounts[id] || 0) + 1;
    if (idCounts[id] > 1) {
        duplicateIds.push(id);
    }
});

// 检查连续性
for (let i = 1; i <= Math.max(...ids); i++) {
    if (!ids.includes(i)) {
        missingIds.push(i);
        isConsecutive = false;
    }
}

// 输出结果
if (duplicateIds.length > 0) {
    console.log(`❌ 发现重复的 id: ${duplicateIds.join(', ')}`);
}

if (missingIds.length > 0) {
    console.log(`❌ 缺失的 id: ${missingIds.slice(0, 10).join(', ')}${missingIds.length > 10 ? '...' : ''}`);
}

if (isConsecutive && duplicateIds.length === 0) {
    console.log('✅ 所有 id 都是连续的，没有重复');
    console.log('✅ 数组结构验证通过');
} else {
    console.log('❌ 数组结构验证失败');
}

// 检查数组语法
try {
    // 简单的语法检查
    const arrayStart = content.indexOf('export const commonEnglishWords: WordItem[] = [');
    const arrayEnd = content.lastIndexOf(']');
    
    if (arrayStart === -1 || arrayEnd === -1) {
        console.log('❌ 数组结构不完整');
    } else {
        console.log('✅ 数组结构完整');
    }
} catch (error) {
    console.log('❌ 语法检查失败:', error.message);
}